feat(react-router): parse regex to calculate accurate types for generatePath#13436
feat(react-router): parse regex to calculate accurate types for generatePath#13436devonpmack wants to merge 3 commits intoremix-run:devfrom
generatePath#13436Conversation
|
|
Hi @devonpmack, Welcome, and thank you for contributing to React Router! Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once. You may review the CLA and sign it by adding your name to contributors.yml. Once the CLA is signed, the If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run. Thanks! - The Remix team |
|
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
39091da to
1dc814b
Compare
generatePath
|
@markdalgleish Hey Mark would it be possible to get this reviewed 🙏 Not sure who would be best to ping. Thank you! |
generatePathgeneratePath
|
I'll check in with the team but I'm not sure if we want to be continuing to try to enhance the type story here now that we have completely revamped the types with our |
|
You're right framework mode would also fix it. But maybe this update is still worthwhile for people who haven't migrated yet? |
|
I'm going to close this for now according to our new Open Governance model. Please feel free to open a proposal for consideration/discussion. |
When calling
generatePath('/pages/:page(comments|latest_activity)')by parsing the regex, we should be able to automatically enforce that thepageparameter is one ofcomments | latest_activity.This PR implements that parsing:
If the path contains regex symbols like
:page(\d+|activity)then it will not try to parse the types.This could be a breaking change if anyone is incorrectly calling generatePath with arguments that aren't part of the
(|)in the regexp.